/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/rng/fortuna/fnaPool.h,v 1.3 2003/11/21 12:39:24 itsme Exp $
 *
 *
 */


#ifndef __FNAPOOL_H__

#include "fnaHashFunction.h"
#include "winMutex.h"

//--------------------------------------------------------------------------
class Pool {
public:
    Pool();
    ~Pool();

    void Initialize();

    void Add(const ByteVector& data);
    void Add(BYTE data);
    size_t GetSize() const;
    ByteVector Use();

    bool WaitForMutex();
    void ReleaseMutex();

private:
    ByteVector m_buffer;
    HashFunction m_hash;
    size_t m_poolsize;

    Mutex m_mutex;

    enum { HASHTHRESHOLD= 1024 };           // in bytes
    void FlushBuffer();
};


#define __FNAPOOL_H__
#endif
